package com.example.product.biz.controller;

import com.alibaba.nacos.api.model.v2.Result;
import com.example.product.biz.domain.dto.CategoryAddDTO;
import com.example.product.biz.service.CategoryService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "分类接口相关")
@Slf4j
@RestController
@RequestMapping("/category")
@RequiredArgsConstructor
public class CategoryController {
    private final CategoryService categoryService;

    @PostMapping
    public Result addCategory(@RequestBody @Validated CategoryAddDTO categoryAddDTO) {
        log.info("新增分类：{}", categoryAddDTO);
        categoryService.addCategory(categoryAddDTO);
        return Result.success();
    }
}
